package models

import (
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
	"shops/conf"
)

var ctx = context.Background()

var (
	Rdb *redis.Client
)

func RedisInit() {
	Rdb = redis.NewClient(&redis.Options{
		Addr:     conf.Cf.RedisConfig.Address,
		Password: conf.Cf.RedisConfig.Password,
		DB:       conf.Cf.RedisConfig.DB,
	})
	err = Rdb.Ping(ctx).Err()
	if err != nil {
		fmt.Println("redis连接失败")
		return
	}
	fmt.Println("redis连接成功")
}
